package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.Admin;
import com.weipai.springboot.model.AdminLoginRecord;
import com.weipai.springboot.model.CustomerCategory;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.dao.AdminDao;
import com.weipai.springboot.module.mapper.AdminLoginRecordMapper;
import com.weipai.springboot.module.mapper.AdminMapper;
import com.weipai.springboot.module.mapper.CustomerCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author LiHaiBo
 * @create 2018-08-20 11:46
 **/
@Repository
public class AdminDaoImpl implements AdminDao {

    @Autowired
    AdminMapper adminMapper;
    @Autowired
    CustomerCategoryMapper customerCategoryMapper;
    @Autowired
    AdminLoginRecordMapper adminLoginRecordMapper;

    @Override
    public Admin getAdminByLoginName(String loginName) {
        return adminMapper.getAdminByLoginName(loginName);
    }

    @Override
    public int verifyCustomerByInviCode(String inviCode) {
        return adminMapper.verifyCustomerByInviCode(inviCode);
    }

    @Override
    public int insert(Admin admin) {
        return adminMapper.insertSelective(admin);
    }

    @Override
    public List<Map<String, Object>> selectAllByDel(int del, String search, String sort, String way) {
        return adminMapper.selectAllByDel(del, search, sort, way);
    }

    @Override
    public Admin getAdminById(String id) {
        return adminMapper.getAdminById(id);
    }

    @Override
    public Admin getAdminByCustomerId(String customerId) {
        return adminMapper.getAdminByCustomerId(customerId);
    }

    @Override
    public int updateByPrimaryKey22(Admin admin) {
        return adminMapper.updateByPrimaryKey22(admin);
    }

    @Override
    public int updateDel(String id) {
        return adminMapper.updateDel(id);
    }

    @Override
    public int batchDeleteById(String[] id) {
        return adminMapper.batchDeleteById(id);
    }

    @Override
    public Admin getAdminByAdminCode(String adminCode) {
        return adminMapper.getAdminByAdminCode(adminCode);
    }

    @Override
    public List<CustomerCategory> getCustomerCategoryList() {
        return customerCategoryMapper.getCustomerCategoryList();
    }

    //记录管理员登录日志
    @Override
    public int saveAdminLoginRecord(AdminLoginRecord adminLoginRecord) {
        return adminLoginRecordMapper.insertSelective(adminLoginRecord);
    }

    @Override
    public List<Map<String, Object>> getAdminLoginRecordList(String adminLoginName, Integer start, Integer size, String startTime, String endTime) {
        return adminLoginRecordMapper.getAdminLoginRecordList(adminLoginName, start, size, startTime, endTime);
    }

    @Override
    public Integer getAdminLoginRecordAmount(String adminLoginName, String startTime, String endTime) {
        return adminLoginRecordMapper.getAdminLoginRecordAmount(adminLoginName, startTime, endTime);
    }
}
